<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class MiniProgram extends Model
{
    use SoftDeletes;
    protected $table = 'mini_program';
    protected $fillable=[ 'name', 'type', 'app_key','app_secret','mchid',
        'api_key','image_id','category_style','share_title','share_desc','description' ];

    protected $appends = ['type_text'];

    public function hasPage()
    {
        return $this->hasMany(MiniProgramPage::class,'mini_id','id');
    }

    public function getTypeTextAttribute()
    {
        $data = mini_program_list();
        return $data[$this->type];
    }


}
